package cdu.javaendwork.Controller.Admin.User;

import cdu.javaendwork.model.sqlModel.User;
import cdu.javaendwork.service.Impl.User.UserServiceImpl;
import cdu.javaendwork.service.Interface.User.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/admin/admin_delete")
public class AdminDeleteController extends HttpServlet {

    UserService userService=new UserServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 找到id
        String aid=req.getParameter("adminid");
        int adminid=Integer.parseInt(aid);
        User user=userService.findById(adminid);

        // 修改
        userService.update(user.getId(),user.getUsername(),user.getPassword(),user.getPhoto(),user.getUserprofile(),user.getPhone(),4);

        req.getRequestDispatcher("admin_list").forward(req,resp);

    }
}
